package com.gopay.solution.domain.bo.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.gopay.solution.domain.po.SolutionRuleDtl;
import com.gopay.solution.domain.po.SsTransPayChanDtl;
import com.gopay.solution.domain.vo.Event;
import com.gopay.solution.domain.vo.Result;

/**
 * 付款渠道方案规则执行器
 * 
 * @SsTransPayChanSoluRuleExecutor.java
 * @author liujy
 * @2013-3-27 下午4:03:49  www.gopay.com.cn Inc.All rights reserved.
 */
@Service(value="ssTransPayChanSoluRuleExecutor")
public class SsTransPayChanSoluRuleExecutor extends AbstractSolutionRuleExecutor {

    @Override
    public Result execute(List<SolutionRuleDtl> rules, Event event) {
        
        
        
        Serializable input = event.getDetail();
        String intTxnCd = (String) input;
        
        ArrayList<SolutionRuleDtl> list = new ArrayList<SolutionRuleDtl>();
        
        if(rules != null && rules.size() > 0) {
            for(SolutionRuleDtl rule : rules) {
                
                SsTransPayChanDtl dtl = (SsTransPayChanDtl)rule;
                if(intTxnCd.equals(dtl.getGopayIntTxnCd())){
                    list.add(dtl);
                }
            }
        }
        
        
        Result res = new Result();
        res.setSolved(true);
        res.setFailedReason("");
        res.setDetail(list);
        
        return res;
    }
    
}
